package com.wsc.service;

import com.wsc.exception.MyNullException;
import com.wsc.mapper.UserMapper;
import com.wsc.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User getByName(String name) {
        return userMapper.getByName(name);
    }

    @Override
    public List<User> getAll() {
        Map<String,String> map = new HashMap<>();
        return userMapper.getAll();
    }

    @Override
    public String nullableTest(@NotNull Object o, String msg) {
        if (o == null){
            throw new MyNullException(msg);
        }
        return o+"不为空";
    }

}
